package com.yanqu.road.server.cmd.marriage;

import com.yanqu.road.entity.servercenter.group.CrossMarriageGroup;
import com.yanqu.road.pb.marriage.CrossMarriageProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.marriage.CrossGroupMarriageMgr;
import com.yanqu.road.server.manger.CrossMarriageGroupMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_MARRIAGE_OVER_TIME_NOTIFY, desc = "跨服联姻超时")
public class CrossMarriageOverTimeCmd extends CrossCommand {

    private String childUid;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossMarriageProto.CrossMarriageOverTimeNotifyMsg reqMsg = CrossMarriageProto.CrossMarriageOverTimeNotifyMsg.parseFrom(packet.getBytes());
        childUid = reqMsg.getChildUid();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossMarriageGroup marriageGroup = CrossMarriageGroupMgr.getCrossMarriageGroupByServerId(serverId);
        if(!CrossMarriageGroupMgr.canCrossMarriage(marriageGroup)){
            return;
        }
        CrossGroupMarriageMgr.dealMarriageOverTime(childUid);
    }

    @Override
    public void sendData() {

    }
}
